-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Feat: Add support for multiple adjacent collections #8553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
useCollectionRef hook to improve controlled collection casesuseCollectionRef hook to improve adjacent child collections
useCollectionRef hook to improve adjacent child collectionsuseCollectionRef hook to support adjacent child collections
| return <Type ref={itemRef}>{children}</Type>; | ||
| } | ||
|
|
||
| export function useCollectionRef<C extends BaseCollection<object>, E extends Element>(props: CollectionRenderProps<C>, ref: Ref<E>): CollectionRef<C, E> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming and argument order is TBD. I was also considering useImperativeCollectionRef or something alike. Open for suggestions here 👍
useCollectionRef hook to support adjacent child collectionsuseCollectionRef hook to support different context for adjacent collections
useCollectionRef hook to support different context for adjacent collections| : useSyncExternalStoreFallback; | ||
|
|
||
| function useCollectionDocument<T extends object, C extends BaseCollection<T>>(createCollection?: () => C): CollectionDocumentResult<T, C> { | ||
| export function useCollectionDocument<T extends object, C extends BaseCollection<T>>(createCollection?: () => C): CollectionDocumentResult<T, C> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please let me know if you’re okay with exporting this. Our use case only requires one-way sync, so we wouldn’t necessarily need it, but I feel that a true sync might be preferable, in which case this would be required.
|
Closing this until feedback for the Rotator/Carousel RFC is in 👍 |
This PR adds support for hooking into the
CollectionBuilderof child collections via a newuseCollectionRefhook. This hook supports the attachment of wrapper hooks to the ref of the collection element, which enables advanced controlled use cases, such as a hoisting multiple collections to a parent component.Background: We make use of this in our
Carousel, which provides a custom collection renderer to implement its scroll controls and infinite loops.Carouselsupports an adjacent collection next to aGridListorListBoxfor the tabbed carousel pattern, so we require a way to target the renderer & builder of specific slots 👍✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project: